<template>
    <div>
        <yh-dialog
            drag
            id="bid-detail-dialog"
            :class="{ 'dialog-content': !isFullScreen }"
            :visible="bidDetailShow"
            :before-close="close"
            :close-on-click-modal="false"
            :fullscreen="isFullScreen"
        >
            <div slot="title" class="dialog-title header">
                <span>{{ isUpdate ? '修改投标指令' : '下达投标指令' }}</span>
                <i class="el-icon-full-screen" style="display: inline-block" @click="handleFullScreen"></i>
            </div>
            <div>
                <div style="border-bottom: 2px solid #98c2fd">
                    <span class="title">债券详情</span>
                </div>
                <div>
                    <span style="font-size: 30px; color: #409eff">{{ rowData.bondNameSt }}</span>
                    <span
                        class="detail-title"
                        style="font-size: 18px; text-decoration: underline; color: #107fff; margin-left: 20px; cursor: default"
                        @click="handleBondRowDetail"
                        >详情</span
                    >
                    <div class="title-box">
                        <span class="title-item">
                            {{ rowData.issueTerm ? '期限：' + rowData.issueTerm + '年' : '期限： ' }}
                        </span>
                        <span class="title-item">票面利率：{{ rowData.yearRate != undefined ? numberFormat(rowData.yearRate, 2) + '%' : '' }}</span>
                        <span class="title-item"
                            >发行规模：{{ rowData.totalBalance != undefined ? numberFormat(rowData.totalBalance, 2) + '亿' : '0' }}</span
                        >

                        <span class="title-item" v-if="rowData.bidSubject == 1">
                            利率区间：<span v-if="rowData.bidSectionLower || rowData.bidSectionUpper">
                                <span style="font-size: 18px">{{
                                    (rowData.bidSectionLower ? numberFormat(rowData.bidSectionLower, 2) : '--') + '%'
                                }}</span>
                                <span class="connect-line"></span>
                                <span style="font-size: 18px">{{
                                    (rowData.bidSectionUpper ? numberFormat(rowData.bidSectionUpper, 2) : '--') + '%'
                                }}</span>
                                <!-- <span style="font-size: 18px;">{{ rowData.bidSectionLower + '%' || '--' }}</span>
                                <span class="connect-line"></span>
                                <span style="font-size: 18px;">{{ rowData.bidSectionUpper + '%' || '--' }}</span> -->
                            </span>
                            <span v-else>--</span>
                        </span>
                        <span class="title-item" v-else>
                            价格区间：<span v-if="rowData.bidSectionLower || rowData.bidSectionUpper">
                                <span style="font-size: 18px">{{
                                    (rowData.bidSectionLower ? numberFormat(rowData.bidSectionLower, 2) : '--') + '元'
                                }}</span>
                                <span class="connect-line"></span>
                                <span style="font-size: 18px">{{
                                    (rowData.bidSectionUpper ? numberFormat(rowData.bidSectionUpper, 2) : '--') + '元'
                                }}</span>
                                <!-- <span style="font-size: 18px;">{{ rowData.bidSectionLower + '元' || '--' }}</span>
                                <span class="connect-line"></span>
                                <span style="font-size: 18px;">{{ rowData.bidSectionUpper + '元' || '--' }}</span> -->
                            </span>
                            <span v-else>--</span>
                        </span>
                    </div>

                    <el-divider></el-divider>
                </div>
            </div>
            <!-- <div>
                <div style="border-bottom: 2px solid #98c2fd">
                    <span class="title">债券详情</span>
                </div>
                <el-form label-width="110px" class="item">
                    <el-row>
                        <el-form-item label="债券简称:">
                            <span>{{ rowData.bondNameSt }}</span>
                            <span style="color: #107fff; margin-left: 20px; cursor: default" @click="handleBondRowDetail">详情</span>
                        </el-form-item>
                    </el-row>
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="期限:">
                                {{ rowData.issueTerm ? rowData.issueTerm + '年' : '' }}
                            </el-form-item></el-col
                        >
                        <el-col :span="6">
                            <el-form-item label="票面利率:">
                                <span>{{ rowData.yearRate != undefined ? numberFormat(rowData.yearRate, 2) + '%' : '' }}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="发行规模:">
                                <span>{{ rowData.totalBalance != undefined ? numberFormat(rowData.totalBalance, 2) + '亿' : '' }}</span>
                            </el-form-item>
                        </el-col>
                        <el-form-item :label="rowData.bidSubject == 1 ? '利率区间:' : '价格区间(元):'">
                            <span>{{ rowData.bidSection || '' }}</span>
                        </el-form-item>
                    </el-row>
                </el-form>
            </div> -->
            <template>
                <div style="border-bottom: 2px solid #98c2fd">
                    <span class="title">投标详情</span>
                </div>
                <div style="display: flex; justify-content: space-between; margin: 10px 0">
                    <div style="display: flex">
                        产品:
                        <el-select
                            name="fund"
                            v-model="selectedFundCode"
                            multiple
                            collapse-tags
                            style="margin: 0 10px; width: 270px"
                            size="mini"
                            placeholder="请选择"
                            filterable
                            :remote-method="getFundCode"
                        >
                            <el-option
                                v-for="item in fundInfoList"
                                :key="item.fundCode"
                                :label="item.fundCode + ' ' + item.fundNameSt"
                                :value="item.fundCode"
                                :name="'fund' + item.fundCode"
                            >
                            </el-option>
                        </el-select>
                        <el-button type="primary" icon="el-icon-circle-plus-outline" size="mini" style="margin-left: 5px" @click="addBid"
                            >增加标位</el-button
                        >
                        <el-button icon="el-icon-delete" size="mini" @click="deleteBid">删除标位</el-button>
                    </div>
                    <div>
                        <i class="el-icon-alarm-clock" style="font-size: 24px; color: #ff4847"></i>
                        <span>{{ rowData.bidRemainTime }}</span>
                    </div>
                </div>
                <div class="table1">
                    <vxe-table
                        border
                        stripe
                        show-overflow
                        ref="xTable"
                        height="200"
                        auto-resize
                        :column-config="{ resizable: true }"
                        :row-config="{ isHover: true }"
                        :data="instructions"
                        @checkbox-all="selectAllChange"
                        @checkbox-change="selectChange"
                        :key="fundDataRenderKey + 'fundDataRenderKey'"
                    >
                        <vxe-column type="checkbox" width="60"></vxe-column>
                        <vxe-column field="fundCode" title="产品序号" width="80"></vxe-column>
                        <vxe-column field="fundName" title="产品名称" show-overflow min-width="100"></vxe-column>
                        <vxe-column field="referencedYield" title="参考收益率(%)" show-overflow min-width="100">
                            <template #default="{ row }">
                                {{ row.referencedYield != undefined ? numberFormat(row.referencedYield, 2) : '--' }}
                            </template>
                        </vxe-column>
                        <vxe-column field="orderPrice" :title="rowData.bidSubject == 1 ? '利率(%)' : '价格(元)'" show-overflow min-width="100">
                            <template #default="{ row }">
                                <vxe-input
                                    v-model="row.orderPrice"
                                    :min="rowData.bidSubject == 1 ? '0.01' : '1'"
                                    step="1"
                                    :type="rowData.bidSubject == 1 ? 'number' : 'integer'"
                                    @blur="blurOrderPrice(row)"
                                    @input="inputOrderPrice(row)"
                                ></vxe-input>
                            </template>
                        </vxe-column>
                        <vxe-column field="orderBalance" title="投标金额(万元)" show-overflow min-width="100">
                            <template #default="{ row }">
                                <vxe-input
                                    v-model="row.orderBalance"
                                    type="integer"
                                    min="1"
                                    @change="changeOrderBalance(row)"
                                    @blur="blurOrderBalance(row)"
                                    @input="inputOrderBalance(row)"
                                ></vxe-input>
                            </template>
                        </vxe-column>
                        <vxe-column field="orderDirection" title="投标方式" show-overflow min-width="120">
                            <template #default="{ row }">
                                <el-select v-model="row.orderDirection">
                                    <el-option v-for="(value, key) in orderDirections" :key="key" :value="key" :label="value"></el-option>
                                </el-select>
                            </template>
                        </vxe-column>
                        <vxe-column field="remark" title="备注" show-overflow min-width="100">
                            <template #default="{ row }">
                                <vxe-input v-model="row.remark" type="text"></vxe-input>
                            </template>
                        </vxe-column>
                    </vxe-table>
                    <el-divider></el-divider>
                    <vxe-table
                        class="table2"
                        border
                        stripe
                        show-overflow
                        auto-resize
                        ref="xTable"
                        height="100"
                        :column-config="{ resizable: true }"
                        :row-config="{ isHover: true }"
                        :data="calcTotalData"
                    >
                        <vxe-column field="fundCode" title="产品序号" width="80"></vxe-column>
                        <vxe-column field="fundName" title="产品名称" show-overflow min-width="100"></vxe-column>
                        <vxe-column field="orderBalance" title="投标金额(万元)" show-overflow>
                            <template #default="{ row }">
                                {{ row.orderBalance != undefined ? numberFormat(row.orderBalance, 4) : '--' }}
                            </template>
                        </vxe-column>
                    </vxe-table>
                </div>
            </template>
            <div class="dialog-footer" slot="footer">
                <el-button type="warning" :disabled="disButStart" @click="handleButton('trial')">风险试算</el-button>
                <el-button type="primary" :disabled="disButStart" @click="handleButton('order')">下达</el-button>
                <el-button @click="handleButton('cancel')">取消</el-button>
            </div>
        </yh-dialog>
        <BondDetail
            v-if="bondDetailShow"
            :bondDetailVisible="bondDetailShow"
            :row="rowData"
            :type="'look'"
            @closeBondDetailDialog="bondDetailShow = false"
        />
        <!-- <yh-dialog
            drag
            id="inner-dialog"
            title="发行债券详情"
            :visible.sync="bondDetailShow"
            custom-class="menu-dialog-height"
            :close-on-click-modal="false"
        >
            <BondDetail :row="rowData" v-if="bondDetailShow"></BondDetail>
            <div slot="footer" class="dialog-footer">
                <el-button size="mini" @click="bondDetailShow = false"> 取 消 </el-button>
            </div>
        </yh-dialog> -->
        <RiskTrialResult
            :riskResultShow="riskResultShow"
            :res="trailData"
            :type="type"
            :stockNameSt="rowData.bondNameSt"
            :isUpdate="true"
            @riskResultReturn="riskResultReturn"
            :key="trailDataNumKey + 'trailDataNumKey'"
            v-if="riskResultShow"
        ></RiskTrialResult>
    </div>
</template>
<script lang="ts">
import { SGU_CACHE } from '@/utils/diction-const-util';
import { UUID, numberFormat } from '@/utils/tools';
import { getUser } from '@/utils/user-util';
import { cancelSeniorBondOrder } from '@/common/api/instruction';
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import XEUtils from 'xe-utils';
import BondDetail from './bond-detail.vue';
import RiskTrialResult from './risk-trial-result.vue';

@Component({
    name: 'BidDetail',
    components: { RiskTrialResult, BondDetail },
})
export default class BidDetail extends Vue {
    numberFormat = numberFormat;
    @Prop() bidDetailShow: boolean;
    @Prop({ default: false }) isUpdate: boolean; // 是否为更新

    private trailData: any = {}; // 试算结果
    private trailDataNumKey: number = -1;
    @Prop() rowData: any;
    private bondKey: string = '';
    private bondDetailShow: boolean = false;

    // 投标方式
    private orderDirections: any = {
        '3': '上市买入',
        K: '一级缴款',
    };

    private fundInfoList: any[] = []; // 所有产品信息

    private instructions: any[] = []; // 表格产品信息

    private calcTotalData: any[] = []; // 投标金额表格

    private fundDataRenderKey: number = 0; // 表格渲染Key

    private selectedFundCode: any[] = []; // 产品下拉编号

    private selectedTable: any[] = []; // 勾选数据

    // private fundInfoListNumKey: number = -1; // 产品Key

    private type: string = ''; // 试算或者下单

    private addNeeded: any[] = []; // 产品下拉信息

    private outOrderBatchCode: string = ''; // 下单号

    private riskResultShow: boolean = false; // 风险试算结果

    private isFullScreen: boolean = false; // 表格放大状态

    private updateRowData: any; // 修改详情

    private addFundModal: any = {
        outerOrderCode: '', // 外部指令序号
        reportCode: '', // 债券代码
        reportName: '', // 债券名称
        fundCode: '', // 产品代码（产品序号）
        fundName: '', // 产品名称
        referencedYield: '0', // 参考收益率
        orderPrice: '100', // 指令价格（价格）
        orderBalance: '1', // 指令金额（投标金额）
        orderDirection: 'K', // 订单方向：一级缴款（分销买入）  K  ,上市买入（债券买入）  3
        remark: '', // 备注
        marketCode: '', // 市场编号
        orderType: '', // 请求类型：1 试算、2 下单
        orderUser: getUser().userCode, // 取当前用户
        operatorTime: '', // 操作时间
        tenderWay: '', // 投标方式
    };
    private disButStart: boolean = false; // 下达按钮状态

    async mounted() {
        // console.log(this.rowData, 'rowData');
        // 产品

        // await this.getSelectValue();
        // this.fundInfoList = await this.getSelectValue2();

        this.fundInfoList = await this.getFundCode('');

        if (this.isUpdate) {
            this.$axios.get('/instruction/seniorBondBatchOrder/history/' + this.rowData.bidNo).then((res: any) => {
                this.updateRowData = res;
                this.updateRowData.forEach(ele => {
                    ele.referencedYield = ele.referencedYield ? ele.referencedYield : '0';
                    ele.reportName = this.rowData.bondNameSt;
                    ele.marketCode = this.rowData.marketCode;
                    ele.subject = this.rowData.bidSubject ? this.rowData.bidSubject : '';
                    ele.orderUser = getUser().userCode;
                    ele.fundName = this.fundInfoList.filter(item => ele.fundCode == item.fundCode)[0].fundName;
                    ele.reportCode = this.rowData.bondCode.split(' ')[0];
                });
                this.instructions = this.updateRowData;
                this.getTotalData();
            });
        }

        this.addFundModal.reportCode = this.rowData.bondCode.split(' ')[0];
        this.addFundModal.reportName = this.rowData.bondNameSt;
        this.addFundModal.marketCode = this.rowData.marketCode;
        this.addFundModal.subject = this.rowData.bidSubject ? this.rowData.bidSubject : '';
    }

    @Watch('rowData', { immediate: true, deep: true })
    watchRowData(newData) {
        if (newData) {
            if (newData.bidSubject && newData.bidSubject === '1') {
                this.addFundModal.orderPrice = 1;
            }
        }
    }

    // 增加标位
    private addBid() {
        if (this.selectedFundCode.length < 1) {
            this.yh_message_success('未选择基金产品');
            return;
        }
        this.addNeeded = [];
        this.selectedFundCode.forEach(element => {
            let data = this.fundInfoList.filter(ele => ele.fundCode === element);
            let data2 = Object.assign(JSON.parse(JSON.stringify(this.addFundModal)), { fundCode: element, fundName: data[0].fundNameSt });
            this.addNeeded.push(data2);
        });
        this.instructions = this.instructions.concat(this.addNeeded);
        this.fundDataRenderKey++;
        this.yh_message_success('新增成功');
        this.changeOrderBalance();
    }

    // 删除标位
    private deleteBid() {
        if (this.selectedTable.length < 1) {
            this.yh_message_warn('请先勾选待删除标位');
            return;
        }
        this.selectedTable.forEach(item => {
            let key = this.instructions.findIndex(ele => ele._XID === item._XID);
            this.instructions.splice(key, 1);
        });
        this.fundDataRenderKey++;
        this.yh_message_success('删除成功');
        this.getTotalData();
    }

    // 产品多选框数据源
    private getSelectValue(): void {
        this.fundInfoList = [];
        this.$axios({
            url: '/primaryBond/select',
            method: 'get',
        }).then((res: any) => {
            for (let fundInfo of res.fundSelect || []) {
                this.fundInfoList.push({
                    dictKey: fundInfo.code,
                    dictKeyName: fundInfo.name,
                    fundCode: fundInfo.code,
                    fundName: fundInfo.name,
                });
            }
            this.fundInfoList.sort((a, b) => {
                return parseInt(a.dictKey) - parseInt(b.dictKey);
            });
        });
    }

    private getSelectValue2(): any {
        let fundInfoList = [];
        return new Promise((resolve, reject) => {
            this.$axios({
                url: '/primaryBond/select',
                method: 'get',
            }).then((res: any) => {
                for (let fundInfo of res.fundSelect || []) {
                    fundInfoList.push({
                        dictKey: fundInfo.code,
                        dictKeyName: fundInfo.name,
                        fundCode: fundInfo.code,
                        fundName: fundInfo.name,
                    });
                }
                fundInfoList.sort((a, b) => {
                    return parseInt(a.dictKey) - parseInt(b.dictKey);
                });

                resolve(fundInfoList);
            });
        });
    }

    private getFundCode(val: any): any {
        let fundInfoList = [];
        return new Promise((resolve, reject) => {
            this.$axios.get('/fundInfo/list/byUser/like?fundCodeOrName=' + val).then((res: any) => {
                fundInfoList = res;
                resolve(fundInfoList);
            });
        });
    }

    // 汇总投标金额
    private getTotalData(): void {
        this.calcTotalData = [];
        let data = [];
        this.instructions.forEach(item => {
            if (data.includes(item.fundCode)) {
                let index = this.calcTotalData.findIndex(ele => ele.fundCode === item.fundCode);
                let value1 = this.calcTotalData[index].orderBalance == '' ? 0 : parseInt(this.calcTotalData[index].orderBalance);
                let value2 = item.orderBalance == '' ? 0 : parseInt(item.orderBalance);
                let calcValue = value1 + value2;
                this.calcTotalData[index].orderBalance = calcValue.toString();
            } else {
                this.calcTotalData.push(JSON.parse(JSON.stringify(item)));
                data.push(item.fundCode);
            }
        });
        let keys = XEUtils.map(this.calcTotalData, item => item.fundCode);

        this.selectedFundCode = keys;
    }

    // // 产品下拉框
    // private customSelectReturn(value) {
    //     this.selectedFundCode = value;
    // }

    // 按钮处理
    private handleButton(type: string): void {
        this.type = type;
        if (type === 'trial' || type === 'order') {
            if (this.instructions.length < 1) {
                this.yh_message_error('投标详情不能为空，请先配置投标详情');
                return;
            }
            this.getTrial(type);
        } else if (type === 'cancel') {
            // this.close();
            this.close('cancel');
        }
    }

    // 试算
    private getTrial(type: string): void {
        let continued = false;
        let flag = false;
        this.instructions.forEach(element => {
            let codes = this.instructions.filter(item => item.fundCode == element.fundCode);

            if (codes) {
                let funds = codes.filter(ele => ele.orderPrice == element.orderPrice);
                if (funds.length > 1) {
                    continued = true;
                    return;
                }
            }
            if (this.rowData.bidSectionLower) {
                if (Number(element.orderPrice) < Number(this.rowData.bidSectionLower)) {
                    flag = true;
                    return;
                }
            }
            if (this.rowData.bidSectionUpper) {
                if (Number(element.orderPrice) > Number(this.rowData.bidSectionUpper)) {
                    flag = true;
                    return;
                }
            }
        });
        if (continued) {
            this.yh_message_error('同一产品价格不能相等!');
            return;
        }

        if (flag) {
            this.yh_message_error('价格或利率应在区间内');
            return;
        }
        this.disButStart = true;
        this.instructions.forEach(item => {
            item.orderType = '1';
            item.operatorTime = XEUtils.toDateString(new Date(), 'yyyyMMddHHmmss');
            item.outerOrderCode = 'tob' + UUID() + '-' + new Date().getTime();
            item.payDate = this.rowData.payDate;
            item.fundAccountCode = ' ';
            item.tenderWay = item.orderDirection;
        });
        this.$axios
            .post('/dataEngine/seniorBondBatchOrder', {
                outOrderBatchCode: 'tob' + UUID() + '-' + new Date().getTime(),
                // 请求id
                requestId: 'rtob' + UUID() + '-' + new Date().getTime(),
                // 下单人姓名
                tradeUser: getUser().userCode,
                tradeUserName: getUser().userNickName,
                bidNo: this.isUpdate ? this.rowData.bidNo : '',
                orderType: '1',
                multiType: '1',
                instList: this.instructions,
                stockCode: this.rowData.bondCode,
            })
            .then((res: any) => {
                this.trailData = res;
                this.disButStart = false;
                if (type == 'trial') {
                    if (res.thresholdType == '0') {
                        this.yh_message_success('风控试算通过');
                    }
                } else if (type == 'order') {
                    if (res.thresholdType === '0') {
                        if (this.isUpdate) {
                            // 撤单
                            this.cancelOrder();
                            return;
                        }
                        // 下达结果为合规0
                        this.getOrder();
                        return;
                    }

                    if (this.isUpdate) {
                        // 修改：试算->撤单
                        this.cancelOrder();
                        return;
                    }
                }

                this.riskResultShow = true;
                this.trailDataNumKey++;
            })
            .catch(() => {
                this.disButStart = false;
            });
    }

    // 默认为合规的直接调用
    private getOrder() {
        this.instructions.forEach(item => {
            item.orderType = '2';
        });
        this.$axios
            .post('/dataEngine/seniorBondBatchOrder', {
                outOrderBatchCode: 'tob' + UUID() + '-' + new Date().getTime(),
                requestId: 'rtob' + UUID() + '-' + new Date().getTime(),
                tradeUser: getUser().userCode,
                tradeUserName: getUser().userNickName,
                bidNo: this.isUpdate ? this.rowData.bidNo : '',
                orderType: '2',
                cancelType: '4',
                multiType: '1',
                instList: this.instructions,
                stockCode: this.rowData.bondCode,
            })
            .then((res: any) => {
                this.yh_message_success('指令下达成功');
                // 清空指令
                this.riskResultShow = false;
                // this.close();
                this.close('order');
            });
    }

    // 撤单
    private cancelOrder(): void {
        let outerOrderCodes = this.instructions.map(item => {
            return item.outerOrderCode;
        });
        // 对已下单的指令发起撤单并删除
        cancelSeniorBondOrder({
            cancelOrderType: '2',
            tradeUser: getUser().userCode, // 当前用户
            tradeUserName: getUser().userName, // 当前用户
            orderType: '4',
            instructionType: '10',
            instNo: '',
            originOuterOrderCode: this.instructions[this.instructions.length - 1].outerOrderCode, // 批量指令撤单取最后一个外部指令编号
            delOriginOuterOrderCodeList: outerOrderCodes,
            outerOrderCode: UUID() + '-' + new Date().getTime(),
            requestId: UUID() + '-' + new Date().getTime(),
        }).then((res: any) => {
            // 撤单成功进行下单
            if (this.trailData.thresholdType === '0' && this.type === 'order' && this.isUpdate) {
                // 试算结果为合规0
                this.getOrder();
                return;
            }
            this.riskResultShow = true;
            this.trailDataNumKey++;
        });
    }

    // 风险试算结果
    private riskResultReturn(type: string): void {
        if (type === 'continue') {
            this.getOrder();
        } else if (type === 'cancel') {
            this.riskResultShow = false;
        } else if (type === 'clear') {
            // 清除处理
            // 清空指令
            this.instructions = [];
            this.selectedFundCode = [];
            this.calcTotalData = [];
        }
    }

    // 处理债券行详情
    private handleBondRowDetail() {
        this.bondKey = this.rowData.bondCode;
        this.bondDetailShow = true;
    }

    // 关闭本页面
    private close(type) {
        // 清空指令
        this.instructions = [];
        this.selectedFundCode = [];
        this.calcTotalData = [];
        this.$emit('bidDetailReturn', type);
        // this.$emit('bidDetailReturn', 'cancel');
    }

    // 处理全屏
    private handleFullScreen() {
        this.isFullScreen = !this.isFullScreen;
    }

    private selectChange(value: any): void {
        this.selectedTable = value.selection;
    }

    private selectAllChange(value: any): void {
        this.selectedTable = value.selection;
    }

    // 投资金额变化时
    private changeOrderBalance(row?): void {
        this.getTotalData();
    }

    // 投标金额失去焦点
    private blurOrderBalance(row): void {
        if ((row && row.orderBalance == '') || (row && row.orderBalance < 1)) {
            row.orderBalance = '1';
            this.changeOrderBalance(); //
        }
    }

    // 投标金额获得焦点
    private inputOrderBalance(row): void {
        if (row && row.orderBalance == '') {
            row.orderBalance = '';
            return;
        }
        if (row && row.orderBalance.indexOf('-') != '-1') {
            row.orderBalance = row.orderBalance.substring(0, row.orderBalance.indexOf('-'));
        }

        if (row && row.orderBalance.indexOf('.') != '-1') {
            row.orderBalance = row.orderBalance.substring(0, row.orderBalance.indexOf('.'));
        }
        if (row.orderBalance.length > 8) {
            row.orderBalance = row.orderBalance.slice(0, 8);
        }
    }

    // 价格失去焦点
    private blurOrderPrice(row): void {
        if (row && !row.orderPrice) {
            row.orderPrice = '1';
        }
    }

    // 价格获得焦点
    private inputOrderPrice(row): void {
        if (row && row.orderPrice == '') {
            row.orderPrice = '';
            return;
        }

        if (row && row.orderPrice.indexOf('-') != '-1') {
            row.orderPrice = row.orderPrice.substring(0, row.orderPrice.indexOf('-'));
            return;
        }

        if (row.orderPrice.split('.')[1] && row.orderPrice.split('.')[1].length > 2) {
            row.orderPrice = parseFloat(row.orderPrice).toFixed(2).toString();
        }

        if (row.orderPrice.length > 10) {
            row.orderPrice = row.orderPrice.slice(0, 10);
        }
    }
}
</script>

<style lang="scss" scoped>
.connect-line {
    width: 9px;
    display: inline-block;
    height: 1.5px;
    background: #575757;
    margin: 0 5px;
    vertical-align: middle;
}
.title-box {
    display: inline-block;
    padding-left: 30px;
    .title-item {
        padding-right: 30px;
        font-size: 18px;
    }
}
.title {
    display: inline-block;
    height: 32px;
    line-height: 32px;
    text-align: center;
    width: 135px;
    border-top-right-radius: 30%;
    background: rgb(97, 160, 253);
    color: #fff;
}
/deep/ .el-form-item {
    margin-bottom: 0px !important;
}

#bid-detail-dialog {
    /deep/ .el-dialog {
        min-width: 1000px;
        .el-dialog__body {
            max-height: none;
        }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 42px;
            line-height: 42px;
            margin-right: 20px;
        }
    }
}

.dialog-content /deep/ .el-dialog {
    margin-top: 1vh !important;
}
#inner-dialog /deep/ .el-dialog {
    min-width: 1000px;
}
/deep/ .vxe-input:not(.is--disabled).is--active .vxe-input--inner {
    border: 1px solid #62b4f7;
}
/deep/ .el-divider--horizontal {
    margin: 10px 0;
}

/deep/ span.el-tag.el-tag--info.el-tag--mini.el-tag--light {
    display: flex;
    align-items: center;
    .el-select__tags-text {
        display: inline-block;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
/deep/ .menu-dialog-height {
    margin-top: 5vh !important;
    .el-dialog__body {
        max-height: 90vh;
        overflow: scroll;
        &::-webkit-scrollbar {
            width: 8px !important;
            height: 4px !important;
        }

        &::-webkit-scrollbar-thumb {
            background-color: #727272;
            border-radius: 0px;
        }
    }
}

/deep/ .el-select .el-tag {
    margin-bottom: 6px !important;
}
</style>
